import { PORT2, PORT1 } from "@/api/config/servicePort";
import http from "@/api";
import { Login, Chat } from "@/api/interface/index";

/**
 * @name 登录模块
 */
// *
export const loginApi = (params: Login.ReqLoginForm) => {
	return http.post<Login.ResLogin>(PORT2 + `/api/v1/user/login`, params, { headers: { noLoading: true } }); // 正常 post json 请求  ==>  application/json
};

/**
 * @name 自动消息列表
 */
// *
export const autoChatList = (params: Chat.autoChat) => {
	return http.get(PORT2 + `/api/v1/message/list`, params)
};
/**
 * @name 自动消息-新增
 */
// *
export const autoChatAdd = (params: Chat.autoChatAdd) => {
	params.status == undefined && (params.status = 0);
	return http.post(PORT2 + `/api/v1/message/create`, params)
};
/**
 * @name 自动消息-编辑
 */
// *
export const autoChatEdit = (hparams: Chat.autoChatEdit) => {
	const { id, ...params } = hparams;
	return http.put(PORT2 + `/api/v1/message/update/${id}`, params)
};
/**
 * @name 自动消息-删除
 */
// *
export const autoChatDelete = (id: number) => {
	return http.delete(PORT2 + `/api/v1/message/delete/${id}`)
};

/**
 * @name all-登录
 */
// *
export const allLogin = (params: any) => {
	return http.post(PORT1 + `/users/admin/login`, params)
};
/**
 * @name all-用户信息更新
 */
// *
export const allUpdateUser = (params: any, header: any) => {
	return http.post(PORT1 + `/users/admin/update`, params, header)
};
